package com.neu.wangweili.servlet;

import com.alibaba.fastjson.JSONObject;
import com.neu.wangweili.service.W_DorService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import java.util.Map;

@WebServlet(name = "W_AjaxDorServlet", urlPatterns = {"/W_AjaxDorServlet"})
public class W_AjaxDorServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String dor_build=request.getParameter("dorBuild");
        System.out.println("dor_build"+dor_build);
        W_DorService w_dorService=new W_DorService();
        List<Map<String,Object>> list=w_dorService.findByBuild(dor_build);
        String str="";
        if (list.size()>0){
            str=JSONObject.toJSONString(list);
        }
        System.out.println("str"+str);
        PrintWriter out=response.getWriter();
        out.write(str);
        out.close();
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);
    }
}
